<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  <title>LCOV - mbi.info - test/interaction_based.hpp</title>
  <link rel="stylesheet" type="text/css" href="../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LTP GCOV extension - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
        <tr>
          <td class="headerItem" width="20%">Current&nbsp;view:</td>
          <td class="headerValue" width="80%" colspan=4><a href="../index.html">directory</a> - <a href="index.html">test</a> - interaction_based.hpp</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Test:</td>
          <td class="headerValue" width="80%" colspan=4>mbi.info</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Date:</td>
          <td class="headerValue" width="20%">2010-01-23</td>
          <td width="20%"></td>
          <td class="headerItem" width="20%">Instrumented&nbsp;lines:</td>
          <td class="headerValue" width="20%">13</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Code&nbsp;covered:</td>
          <td class="headerValue" width="20%">0.0 %</td>
          <td width="20%"></td>
          <td class="headerItem" width="20%">Executed&nbsp;lines:</td>
          <td class="headerValue" width="20%">0</td>
        </tr>
        </table>
      </td>
    </tr>
    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td><pre class="source">
<span class="lineNum">       1 </span>                : //  (C) Copyright Gennadiy Rozental 2005-2008.
<span class="lineNum">       2 </span>                : //  Distributed under the Boost Software License, Version 1.0.
<span class="lineNum">       3 </span>                : //  (See accompanying file LICENSE_1_0.txt or copy at 
<span class="lineNum">       4 </span>                : //  http://www.boost.org/LICENSE_1_0.txt)
<span class="lineNum">       5 </span>                : 
<span class="lineNum">       6 </span>                : //  See http://www.boost.org/libs/test for the library home page.
<span class="lineNum">       7 </span>                : //
<span class="lineNum">       8 </span>                : //  File        : $RCSfile$
<span class="lineNum">       9 </span>                : //
<span class="lineNum">      10 </span>                : //  Version     : $Revision: 49312 $
<span class="lineNum">      11 </span>                : //
<span class="lineNum">      12 </span>                : //  Description : Facilities to perform interaction-based testing
<span class="lineNum">      13 </span>                : // ***************************************************************************
<span class="lineNum">      14 </span>                : 
<span class="lineNum">      15 </span>                : #ifndef BOOST_TEST_INTERACTION_BASED_HPP_112105GER
<span class="lineNum">      16 </span>                : #define BOOST_TEST_INTERACTION_BASED_HPP_112105GER
<span class="lineNum">      17 </span>                : 
<span class="lineNum">      18 </span>                : // Boost.Test
<span class="lineNum">      19 </span>                : #include &lt;boost/test/detail/config.hpp&gt;
<span class="lineNum">      20 </span>                : #include &lt;boost/test/detail/global_typedef.hpp&gt;
<span class="lineNum">      21 </span>                : 
<span class="lineNum">      22 </span>                : #include &lt;boost/test/utils/wrap_stringstream.hpp&gt;
<span class="lineNum">      23 </span>                : 
<span class="lineNum">      24 </span>                : #include &lt;boost/test/detail/suppress_warnings.hpp&gt;
<span class="lineNum">      25 </span>                : 
<span class="lineNum">      26 </span>                : // Boost
<span class="lineNum">      27 </span>                : #include &lt;boost/lexical_cast.hpp&gt;
<span class="lineNum">      28 </span>                : 
<span class="lineNum">      29 </span>                : //____________________________________________________________________________//
<span class="lineNum">      30 </span>                : 
<span class="lineNum">      31 </span>                : // ************************************************************************** //
<span class="lineNum">      32 </span>                : // **************               BOOST_ITEST_EPOINT             ************** //
<span class="lineNum">      33 </span>                : // ************************************************************************** //
<span class="lineNum">      34 </span>                : 
<span class="lineNum">      35 </span>                : #define BOOST_ITEST_EPOINT( description ) \
<span class="lineNum">      36 </span>                :     ::boost::itest::manager::instance().exception_point( BOOST_TEST_L(__FILE__), __LINE__, description )
<span class="lineNum">      37 </span>                : /**/
<span class="lineNum">      38 </span>                : 
<span class="lineNum">      39 </span>                : // ************************************************************************** //
<span class="lineNum">      40 </span>                : // **************               BOOST_ITEST_DPOINT             ************** //
<span class="lineNum">      41 </span>                : // ************************************************************************** //
<span class="lineNum">      42 </span>                : 
<span class="lineNum">      43 </span>                : #define BOOST_ITEST_DPOINT() \
<span class="lineNum">      44 </span>                :     ::boost::itest::manager::instance().decision_point( BOOST_TEST_L(__FILE__), __LINE__ )
<span class="lineNum">      45 </span>                : /**/
<span class="lineNum">      46 </span>                : 
<span class="lineNum">      47 </span>                : // ************************************************************************** //
<span class="lineNum">      48 </span>                : // **************                BOOST_ITEST_SCOPE             ************** //
<span class="lineNum">      49 </span>                : // ************************************************************************** //
<span class="lineNum">      50 </span>                : 
<span class="lineNum">      51 </span>                : #define BOOST_ITEST_SCOPE( scope_name ) \
<span class="lineNum">      52 </span>                :     ::boost::itest::scope_guard itest_scope_guard ## __LINE__( BOOST_TEST_L(__FILE__), __LINE__, BOOST_STRINGIZE(scope_name) )
<span class="lineNum">      53 </span>                : /**/
<span class="lineNum">      54 </span>                : 
<span class="lineNum">      55 </span>                : // ************************************************************************** //
<span class="lineNum">      56 </span>                : // **************                 BOOST_ITEST_NEW              ************** //
<span class="lineNum">      57 </span>                : // ************************************************************************** //
<span class="lineNum">      58 </span>                : 
<span class="lineNum">      59 </span>                : #define BOOST_ITEST_NEW( type_name ) \
<span class="lineNum">      60 </span>                :     new ( ::boost::itest::location( BOOST_TEST_L(__FILE__), __LINE__ ) ) type_name
<span class="lineNum">      61 </span>                : /**/
<span class="lineNum">      62 </span>                : 
<span class="lineNum">      63 </span>                : // ************************************************************************** //
<span class="lineNum">      64 </span>                : // **************              BOOST_ITEST_DATA_FLOW           ************** //
<span class="lineNum">      65 </span>                : // ************************************************************************** //
<span class="lineNum">      66 </span>                : 
<span class="lineNum">      67 </span>                : #define BOOST_ITEST_DATA_FLOW( v ) \
<span class="lineNum">      68 </span>                :     ::boost::itest::manager::instance().generic_data_flow( v )
<span class="lineNum">      69 </span>                : /**/
<span class="lineNum">      70 </span>                : 
<span class="lineNum">      71 </span>                : // ************************************************************************** //
<span class="lineNum">      72 </span>                : // **************               BOOST_ITEST_RETURN             ************** //
<span class="lineNum">      73 </span>                : // ************************************************************************** //
<span class="lineNum">      74 </span>                : 
<span class="lineNum">      75 </span>                : #define BOOST_ITEST_RETURN( type, default_value ) \
<span class="lineNum">      76 </span>                :     ::boost::itest::manager::instance().generic_return&lt;type&gt;( default_value )
<span class="lineNum">      77 </span>                : /**/
<span class="lineNum">      78 </span>                : 
<span class="lineNum">      79 </span>                : // ************************************************************************** //
<span class="lineNum">      80 </span>                : // **************              BOOST_ITEST_MOCK_FUNC           ************** //
<span class="lineNum">      81 </span>                : // ************************************************************************** //
<span class="lineNum">      82 </span>                : 
<span class="lineNum">      83 </span>                : #define BOOST_ITEST_MOCK_FUNC( function_name )          \
<span class="lineNum">      84 </span>                :     BOOST_ITEST_SCOPE( function_name );                 \
<span class="lineNum">      85 </span>                :     BOOST_ITEST_EPOINT( 0 );                            \
<span class="lineNum">      86 </span>                :     return ::boost::itest::mock_object&lt;&gt;::prototype();  \
<span class="lineNum">      87 </span>                : /**/
<span class="lineNum">      88 </span>                : 
<span class="lineNum">      89 </span>                : namespace boost {
<span class="lineNum">      90 </span>                : 
<span class="lineNum">      91 </span>                : namespace itest { // interaction-based testing
<span class="lineNum">      92 </span>                : 
<span class="lineNum">      93 </span>                : using unit_test::const_string;
<span class="lineNum">      94 </span>                : 
<span class="lineNum">      95 </span>                : // ************************************************************************** //
<span class="lineNum">      96 </span>                : // **************                    manager                   ************** //
<span class="lineNum">      97 </span>                : // ************************************************************************** //
<span class="lineNum">      98 </span>                : 
<span class="lineNum">      99 </span>                : class BOOST_TEST_DECL manager {
<span class="lineNum">     100 </span>                : public:
<span class="lineNum">     101 </span>                :     // instance access
<span class="lineNum">     102 </span>                :     static manager&amp;     instance() { return *instance_ptr(); }
<span class="lineNum">     103 </span>                : 
<span class="lineNum">     104 </span>                :     // Mock objects interface hooks
<span class="lineNum">     105 </span><span class="lineNoCov">              0 :     virtual void        exception_point( const_string /*file*/, </span>
<span class="lineNum">     106 </span>                :                                          std::size_t /*line_num*/, 
<span class="lineNum">     107 </span><span class="lineNoCov">              0 :                                          const_string /*descr*/ ){}</span>
<span class="lineNum">     108 </span><span class="lineNoCov">              0 :     virtual bool        decision_point( const_string /*file*/, </span>
<span class="lineNum">     109 </span><span class="lineNoCov">              0 :                                         std::size_t /*line_num*/ )          { return true; }</span>
<span class="lineNum">     110 </span><span class="lineNoCov">              0 :     virtual unsigned    enter_scope( const_string /*file*/, </span>
<span class="lineNum">     111 </span>                :                                      std::size_t /*line_num*/,
<span class="lineNum">     112 </span><span class="lineNoCov">              0 :                                      const_string /*scope_name*/){ return 0; }</span>
<span class="lineNum">     113 </span><span class="lineNoCov">              0 :     virtual void        leave_scope( unsigned )                             {}</span>
<span class="lineNum">     114 </span><span class="lineNoCov">              0 :     virtual void        allocated( const_string /*file*/, </span>
<span class="lineNum">     115 </span>                :                                    std::size_t /*line_num*/, 
<span class="lineNum">     116 </span><span class="lineNoCov">              0 :                                    void* /*p*/, std::size_t /*s*/ )         {}</span>
<span class="lineNum">     117 </span><span class="lineNoCov">              0 :     virtual void        freed( void* /*p*/ )                                {}</span>
<span class="lineNum">     118 </span><span class="lineNoCov">              0 :     virtual void        data_flow( const_string /*d*/ )                     {}</span>
<span class="lineNum">     119 </span><span class="lineNoCov">              0 :     virtual std::string return_value( const_string /*default_value */ )     { return &quot;&quot;; }</span>
<span class="lineNum">     120 </span>                : 
<span class="lineNum">     121 </span>                :     template&lt;typename T&gt;
<span class="lineNum">     122 </span>                :     void                generic_data_flow( T const&amp; t )
<span class="lineNum">     123 </span>                :     {
<span class="lineNum">     124 </span>                :         wrap_stringstream ws;
<span class="lineNum">     125 </span>                : 
<span class="lineNum">     126 </span>                :         data_flow( (ws &lt;&lt; t).str() );
<span class="lineNum">     127 </span>                :     }
<span class="lineNum">     128 </span>                :     template&lt;typename T, typename DefaultValueType&gt;
<span class="lineNum">     129 </span>                :     T                   generic_return( DefaultValueType const&amp; dv )
<span class="lineNum">     130 </span>                :     {
<span class="lineNum">     131 </span>                :         wrap_stringstream ws;
<span class="lineNum">     132 </span>                : 
<span class="lineNum">     133 </span>                :         std::string const&amp; res = return_value( (ws &lt;&lt; dv).str() );
<span class="lineNum">     134 </span>                : 
<span class="lineNum">     135 </span>                :         if( res.empty() )
<span class="lineNum">     136 </span>                :             return dv;
<span class="lineNum">     137 </span>                : 
<span class="lineNum">     138 </span>                :         return lexical_cast&lt;T&gt;( res );
<span class="lineNum">     139 </span>                :     }
<span class="lineNum">     140 </span>                : 
<span class="lineNum">     141 </span>                : protected:
<span class="lineNum">     142 </span>                :     manager();
<span class="lineNum">     143 </span>                : #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) 
<span class="lineNum">     144 </span>                : public:
<span class="lineNum">     145 </span>                : #endif
<span class="lineNum">     146 </span>                :     BOOST_TEST_PROTECTED_VIRTUAL ~manager();
<span class="lineNum">     147 </span>                : 
<span class="lineNum">     148 </span>                : private:
<span class="lineNum">     149 </span>                :     struct dummy_constr{};
<span class="lineNum">     150 </span><span class="lineNoCov">              0 :     explicit manager( dummy_constr* ) {}</span>
<span class="lineNum">     151 </span>                : 
<span class="lineNum">     152 </span>                :     static manager*     instance_ptr( bool reset = false, manager* ptr = 0 );
<span class="lineNum">     153 </span>                : }; // manager
<span class="lineNum">     154 </span>                : 
<span class="lineNum">     155 </span>                : // ************************************************************************** //
<span class="lineNum">     156 </span>                : // **************                  scope_guard                 ************** //
<span class="lineNum">     157 </span>                : // ************************************************************************** //
<span class="lineNum">     158 </span>                : 
<span class="lineNum">     159 </span>                : class scope_guard {
<span class="lineNum">     160 </span>                : public:
<span class="lineNum">     161 </span>                :     // Constructor
<span class="lineNum">     162 </span>                :     scope_guard( const_string file, std::size_t line_num, const_string scope_name )
<span class="lineNum">     163 </span>                :     {
<span class="lineNum">     164 </span>                :         m_scope_index = manager::instance().enter_scope( file, line_num, scope_name );
<span class="lineNum">     165 </span>                :     }
<span class="lineNum">     166 </span>                :     ~scope_guard()
<span class="lineNum">     167 </span>                :     {
<span class="lineNum">     168 </span>                :         manager::instance().leave_scope( m_scope_index );
<span class="lineNum">     169 </span>                :     }
<span class="lineNum">     170 </span>                : 
<span class="lineNum">     171 </span>                :     unsigned m_scope_index;
<span class="lineNum">     172 </span>                : };
<span class="lineNum">     173 </span>                : 
<span class="lineNum">     174 </span>                : // ************************************************************************** //
<span class="lineNum">     175 </span>                : // **************                    location                  ************** //
<span class="lineNum">     176 </span>                : // ************************************************************************** //
<span class="lineNum">     177 </span>                : 
<span class="lineNum">     178 </span>                : struct location {
<span class="lineNum">     179 </span>                :     location( const_string file, std::size_t line ) 
<span class="lineNum">     180 </span>                :     : m_file_name( file )
<span class="lineNum">     181 </span>                :     , m_line_num( line )
<span class="lineNum">     182 </span>                :     {}
<span class="lineNum">     183 </span>                : 
<span class="lineNum">     184 </span>                :     const_string    m_file_name;
<span class="lineNum">     185 </span>                :     std::size_t     m_line_num;
<span class="lineNum">     186 </span>                : };
<span class="lineNum">     187 </span>                : 
<span class="lineNum">     188 </span>                : }  // namespace itest
<span class="lineNum">     189 </span>                : 
<span class="lineNum">     190 </span>                : } // namespace boost
<span class="lineNum">     191 </span>                : 
<span class="lineNum">     192 </span>                : // ************************************************************************** //
<span class="lineNum">     193 </span>                : // **************              operator new overload           ************** //
<span class="lineNum">     194 </span>                : // ************************************************************************** //
<span class="lineNum">     195 </span>                : 
<span class="lineNum">     196 </span>                : #if !defined(BOOST_ITEST_NO_NEW_OVERLOADS)
<span class="lineNum">     197 </span>                : 
<span class="lineNum">     198 </span>                : // STL
<span class="lineNum">     199 </span>                : #include &lt;cstdlib&gt;
<span class="lineNum">     200 </span>                : 
<span class="lineNum">     201 </span>                : # ifdef BOOST_NO_STDC_NAMESPACE
<span class="lineNum">     202 </span>                : namespace std { using ::malloc; using ::free; }
<span class="lineNum">     203 </span>                : # endif
<span class="lineNum">     204 </span>                : # ifdef _CRTDBG_MAP_ALLOC
<span class="lineNum">     205 </span>                : namespace std { using ::_malloc_dbg; using ::_free_dbg; }
<span class="lineNum">     206 </span>                : # endif
<span class="lineNum">     207 </span>                : 
<span class="lineNum">     208 </span>                : inline void*
<span class="lineNum">     209 </span>                : operator new( std::size_t s, ::boost::itest::location const&amp; l )
<span class="lineNum">     210 </span>                : {
<span class="lineNum">     211 </span>                :     void* res = std::malloc(s ? s : 1);
<span class="lineNum">     212 </span>                : 
<span class="lineNum">     213 </span>                :     if( res )
<span class="lineNum">     214 </span>                :         ::boost::itest::manager::instance().allocated( l.m_file_name, l.m_line_num, res, s );
<span class="lineNum">     215 </span>                :     else
<span class="lineNum">     216 </span>                :         throw std::bad_alloc();
<span class="lineNum">     217 </span>                :         
<span class="lineNum">     218 </span>                :     return res;
<span class="lineNum">     219 </span>                : }
<span class="lineNum">     220 </span>                : 
<span class="lineNum">     221 </span>                : //____________________________________________________________________________//
<span class="lineNum">     222 </span>                : 
<span class="lineNum">     223 </span>                : inline void*
<span class="lineNum">     224 </span>                : operator new[]( std::size_t s, ::boost::itest::location const&amp; l )
<span class="lineNum">     225 </span>                : {
<span class="lineNum">     226 </span>                :     void* res = std::malloc(s ? s : 1);
<span class="lineNum">     227 </span>                : 
<span class="lineNum">     228 </span>                :     if( res )
<span class="lineNum">     229 </span>                :         ::boost::itest::manager::instance().allocated( l.m_file_name, l.m_line_num, res, s );
<span class="lineNum">     230 </span>                :     else
<span class="lineNum">     231 </span>                :         throw std::bad_alloc();
<span class="lineNum">     232 </span>                :         
<span class="lineNum">     233 </span>                :     return res;
<span class="lineNum">     234 </span>                : }
<span class="lineNum">     235 </span>                : 
<span class="lineNum">     236 </span>                : //____________________________________________________________________________//
<span class="lineNum">     237 </span>                : 
<span class="lineNum">     238 </span>                : inline void
<span class="lineNum">     239 </span>                : operator delete( void* p, ::boost::itest::location const&amp; )
<span class="lineNum">     240 </span>                : {
<span class="lineNum">     241 </span>                :     ::boost::itest::manager::instance().freed( p );
<span class="lineNum">     242 </span>                : 
<span class="lineNum">     243 </span>                :     std::free( p );
<span class="lineNum">     244 </span>                : }
<span class="lineNum">     245 </span>                : 
<span class="lineNum">     246 </span>                : //____________________________________________________________________________//
<span class="lineNum">     247 </span>                : 
<span class="lineNum">     248 </span>                : inline void
<span class="lineNum">     249 </span>                : operator delete[]( void* p, ::boost::itest::location const&amp; )
<span class="lineNum">     250 </span>                : {
<span class="lineNum">     251 </span>                :     ::boost::itest::manager::instance().freed( p );
<span class="lineNum">     252 </span>                : 
<span class="lineNum">     253 </span>                :     std::free( p );
<span class="lineNum">     254 </span>                : }
<span class="lineNum">     255 </span>                : 
<span class="lineNum">     256 </span>                : //____________________________________________________________________________//
<span class="lineNum">     257 </span>                : 
<span class="lineNum">     258 </span>                : #endif
<span class="lineNum">     259 </span>                : 
<span class="lineNum">     260 </span>                : #include &lt;boost/test/detail/enable_warnings.hpp&gt;
<span class="lineNum">     261 </span>                : 
<span class="lineNum">     262 </span>                : #endif // BOOST_TEST_INTERACTION_BASED_HPP_112105GER
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
  <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
  <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LTP GCOV extension version 1.6</a></td></tr>
  </table>
  <br>

</body>
</html>
